package com.iuhao.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.iuhao.web.core.response.O2OJSON;
import com.iuhao.web.core.utils.HttpRequestUtil;
import com.iuhao.web.core.utils.HttpRequestUtils;
import com.iuhao.web.hacker.HttpRequest;
import com.iuhao.web.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * Created by yanhao on 2017/11/11.
 */
@Api(tags = "OrderController", description = "订单接口")
@RestController
@RequestMapping("/order")
public class OrderController extends BaseController{

    /***

     {
     "phone": "18610685281", "sourceType": 0, "type": "register", "verification": "", "smsCode": "", "token": ""
     }


    Accept-Encoding:gzip, deflate, br
    Accept-Language:zh-CN,zh;q=0.8
    Connection:keep-alive
    Content-Length:98
    Content-Type:application/json
    Cookie:sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%22160009a130c97e-07fc42a7810504-474f0820-2073600-160009a130d915%22%2C%22%24device_id%22%3A%22160009a130c97e-07fc42a7810504-474f0820-2073600-160009a130d915%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_referrer_host%22%3A%22%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_utm_source%22%3A%2212JZ_fenghuob%22%7D%7D; gdxidpyhxdE=%2FD422YRbgJUQ7a%2Fhohipg%5CJQ02AbKbkiVzSp%2BMCvA6r0OoAKnJHvR3I32VOTeHMY%2FBw3XmvljAaNVKtZd2xkuYksmD7DzUrs%2FBbl2MOv065iJDVBaC83Db2Y1oE7ovcXDiCbTxvVQhQ7x9fSeYH%5CpNn%5CX4bO9XQKOQG%2FXY5tq%2BCe5fpI%3A1513058523376; _9755xjdesxxd_=32
    device_id:16faabf8e9a3d1c50d01ff53d89edf30
    Host:m.yaoqianhua.com
    Origin:https://m.yaoqianhua.com
    Referer:https://m.yaoqianhua.com/
    User-Agent:Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Mobile Safari/537.36
    X-Requested-With:XMLHttpRequest


     *
     */


    @Autowired
    private OrderService orderService;

    @PostMapping(value = "/sms")
    @ApiOperation(value = "sms")
    public O2OJSON testSmsCON() {
        //TODO 多线程 多ip
        O2OJSON json = new O2OJSON();
        JSONObject object = new JSONObject();

        String phone="15687199426";

        final  String url = "https://m.yaoqianhua.com/yaoqianhua-gateway/authenticationService/getSMSCode";
        json.put("phone",phone);
        json.put("sourceType",0);
        json.put("type","register");
        json.put("verification","");
        json.put("smsCode","");
        json.put("token","");

        try {

            O2OJSON result = HttpRequestUtils.doPost(url, JSONObject.toJSONString(json), O2OJSON.class);
            log.info(result+"");
        } catch (Exception e) {
            log.error(e+"");

        }
        return json;
    }
}
